<?php
include_once $_SERVER['DOCUMENT_ROOT'].'/functions/bdd/init.php';

function get_credits(){
	$bdd = bdd_init();
	
	$prep_get_credits = $bdd->prepare('SELECT * FROM messages WHERE cle=?');
	$prep_get_credits->execute(array('credits'));
	$credits = $prep_get_credits->fetch();	
	
	return $credits['value']; 
}

function set_credits($credits){
	$cle = 'credits';
	$bdd = bdd_init();
	
	$prep_set_credits = $bdd->prepare('UPDATE messages SET value = :value WHERE cle=:cle');
	$prep_set_credits->bindParam(':cle', $cle);
	$prep_set_credits->bindParam(':value', $credits);
	$prep_set_credits->execute();
}
?>
